<template>
  <div class="expenditure-details">
    <div class="classification-name">分类名称：一级分类</div>

    <div class="rank">
      <p class="title">您在一级分类下的供应商采购排名：</p>
      <div class="content">
        <div class="item" :class="index === 2 && 'myself'" v-for="(item, index) in 10" :key="index">
          <div class="index">NO.{{ index + 1 }}</div>
          <div class="name">xxxxx公司</div>
        </div>
      </div>
      <div class="total">共采购：94000.20元</div>
    </div>

    <div class="table-wrap">
      <div class="head">
        <div class="title">采购记录</div>
        <m-button type="bordered">导出</m-button>
      </div>

      <div class="table">
        <Table :data="records" :border="true" :span-method="handleSpanMethod">
          <table-column prop="date" label="时间" align="center" width="190"/>
          <table-column prop="company" label="公司名称" align="center"/>
          <table-column prop="name" label="产品名称" align="center"/>
          <table-column prop="count" label="数量" align="center" width="120"/>
          <table-column prop="price" label="单价" align="center" width="120">
            <template v-slot="{ row }">
              ￥{{ row.price }}
            </template>
          </table-column>
          <table-column prop="total" label="总额" align="center">
            <template v-slot="{ row }">
              {{ row.total }}元
            </template>
          </table-column>
        </Table>
      </div>

      <m-pagination :pagination="pages"/>
    </div>
  </div>
</template>

<script>
import MButton from '@/components/common/m-button/MButton'
import MPagination from '@/components/common/m-pagination/MPagination'
import { Table, TableColumn } from 'element-ui'

export default {
  name: 'ExpenditureDetails',
  components: { MPagination, MButton, Table, TableColumn },
  data() {
    return {
      records: [],
      pages: 0
    }
  },
  methods: {
    handleSpanMethod({ row, columnIndex }) {
      if ([0, 5].includes(columnIndex)) {
        if (row.start) {
          return {
            colspan: 1,
            rowspan: row.length
          }
        } else {
          return {
            colspan: 0,
            rowspan: 0
          }
        }
      }
    }
  },
  created() {
    // todo 缺少接口
  }
}
</script>

<style lang="scss" scoped>
@import "~@/assets/style/common.scss";
/deep/ .m-button .el-button{
		height: 32px !important;
}
.expenditure-details {
  .classification-name {
    font-size: 18px;
    margin-bottom: 15px;
  }

  .rank {
    border-bottom: solid 1px #eaeaea;
    padding-bottom: 30px;
    margin-bottom: 30px;

    > .title {
      margin-bottom: 40px;
    }

    > .content {
      margin-bottom: 40px;

      > .item {
        width: 20%;
        display: inline-flex;

        .index {
          font-size: 18px;
          margin-right: 15px;
        }
      }

      .myself {
        color: $theme-color-1;
      }
    }

    > .total {
      font-size: 20px;
      color: $theme-color-1;
      font-weight: bold;
    }
  }

  .table-wrap {
    .head {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-bottom: 15px;
    }

    .table {
      margin-bottom: 15px;

      /deep/ .el-table th, .el-table tr {
        background-color: #F3F4F7;
        color: #666;
        border: none;
        border-bottom: solid 1px #eaeaea;
      }
    }
  }
}
</style>
